<?php

declare(strict_types=1);

namespace App\Model\PssModel;

use App\Model\BaseModel\BasePssModel;
class ShopSeckillUserGoods extends BasePssModel
{
    public $table = 'shop_seckill_user_goods';
    
    /**
     * 查询用户商品秒杀限购情况
     * @param number $bid
     * @param string $skuid
     * @param string $seckill_id
     */
    public function queryUserSecSkillGoodsBuy( $bid = 0 ,$seckill_id = '',$skuid = '',$buy_number = 0 ) 
    {
        $seckillInfo = ShopSeckill::instance()->getSeckillInfoBySecId($seckill_id);
        if( empty($seckillInfo) || $seckillInfo['buy_limit_number'] <= 0 ) {
            return true;
        }
        
        $info = $this->where('bid',$bid)
        ->where('seckill_id',$seckill_id)
        ->where('seckill_goods_id',$skuid)
        ->where('buy_count','>',$buy_number)
        ->first();
        return empty($info) ? true : false;
    }
}
